﻿@model AutomatedTestDataManagement.Models.PagesField

@{
    ViewBag.Title = "Delete";
}

<h2>Remove Field from Page</h2>

<h3>Are you sure you want to remove @Model.HTMLField.FieldName from @Model.Page.PageName?</h3>
<fieldset>
    <legend>PagesField</legend>

    <div class="display-label">
         @Html.LabelFor(model => model.Page.PageName, "Page Name")
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.Page.PageName)
    </div>

    <div class="display-label">
         @Html.LabelFor(model => model.HTMLField.FieldName, "Field Name")
    </div>
    <div class="display-field">
        @Html.DisplayFor(model => model.HTMLField.FieldName)
    </div>
</fieldset>
@using (Html.BeginForm()) {
    <p>
        @if(ViewBag.SiteID != null)
        {
            <input type="hidden" id="SiteID" name="SiteID" value="@ViewBag.SiteID" />
        }
        @if (ViewBag.FieldID != null)
        {
            <input type="hidden" id="FieldID" name="FieldID" value="@ViewBag.FieldID" />
        }
        <input type="submit" value="Delete" /> |
        @if (ViewBag.SiteID != null)
        {
            if(ViewBag.ReturnToView == "Edit")
            {
                @Html.ActionLink("Return to Page", "Edit", "Page", new { id = Model.PageID, siteID = ViewBag.SiteID }, null)
            }
            else
            {
                @Html.ActionLink("Return to Page", "Delete", "Page", new{ id = Model.PageID, siteID = ViewBag.SiteID }, null)
            }
        }
        else 
        {
            if(ViewBag.ReturnToView == "Edit")
            {
                @Html.ActionLink("Return to Page", "Edit", "Page", new { id = Model.PageID }, null)
            }
            else
            {
                if (ViewBag.FieldID == null)
                {
                    @Html.ActionLink("Return to Page", "Delete", "Page", new { id = Model.PageID }, null)
                }
                else
                {
                    @Html.ActionLink("Return to Field", "Delete", "HTMLField", new { id = ViewBag.FieldID }, null)
                }
            }
        }
    </p>
}
<div>
    @Html.Partial("_NavigationManagementNav")
</div>